package com.woniuxy.oldmanapi.service;

import com.woniuxy.oldmanapi.entity.Building;
import com.woniuxy.oldmanapi.mapper.BuildingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BuildingService {

    @Autowired
    BuildingMapper buildingMapper;

    public List<Building> findBuildings() {
        List<Building> BuildingList = buildingMapper.selectAll();
        return BuildingList;
    }

    public int add(Building building) {
        return buildingMapper.insert(building);
    }

    public void delete(int id) {
        buildingMapper.deleteByPrimaryKey(id);
    }

    public void modify(Building building) {
        buildingMapper.updateByPrimaryKey(building);
    }

    public Building selectOne(int id) {
        return buildingMapper.selectByPrimaryKey(id);
    }

    public int findBuildingNum() {
        return buildingMapper.selectNum();
    }

    public List<Building> selectAllList() {
        return buildingMapper.selectAll();
    }

    public Building findOne(Building building) {
        return buildingMapper.selectOneByExample(building);
    }
}
